package com.yanfan.modbus.exception;


import com.yanfan.modbus.frame.abs.ModbusRequest;
import com.yanfan.modbus.frame.abs.ModbusResponse;

/**
 * @author oliver foo
 * @description
 * @date 2022/3/16 13:13
 */
public class ErrorResponseException extends Exception {
    private static final long serialVersionUID = -1;

    private final ModbusRequest originalRequest;
    private final ModbusResponse errorResponse;


    public ErrorResponseException(ModbusRequest originalRequest, ModbusResponse errorResponse) {
        this.originalRequest = originalRequest;
        this.errorResponse = errorResponse;
    }


    public ModbusResponse getErrorResponse() {
        return errorResponse;
    }


    public ModbusRequest getOriginalRequest() {
        return originalRequest;
    }

    @Override
    public String getMessage() {
        return errorResponse.getExceptionMessage();
    }
}
